<template>
  <div class="page-right">
    <ChangeSetType v-model="setType" />
    <div v-show="setType===1">
      <!-- 页面设置 -->
      <SetPageInfo />
    </div>
    <div v-show="setType===2">
      <!-- 组件设置 -->
      <ComTitle :title="currentComponent&&currentComponent.name ||'组件管理'" />
      <ComValidTime v-if="currentComponent" v-model="currentComponent.data.validTime" />
      <component :is="currentComponent.data.component"
                 v-if="currentComponent"
                 :key="currentComponent.id"
                 :parmes="currentComponent.data"
                 @editComponent="editComponent"
      />
      <Noselect v-else />
    </div>
  </div>
</template>

<script>
import ChangeSetType from './ChangeSetType/index.vue'
import SetPageInfo from './SetPageInfo'
import ComValidTime from '@/components/BasicUi/ComValidTime'
import ComTitle from '@/components/BasicUi/ComTitle'
import {mapState, mapActions} from 'vuex'
import {dynamicComponents} from '@/utils'
import Noselect from './Noselect/index.vue'
export default {
  name: 'PageRight',
  components: {
    ChangeSetType,
    SetPageInfo,
    ComValidTime,
    ComTitle,
    ...dynamicComponents(),
    Noselect
  },
  computed: {
    ...mapState(['pageData', 'activeComponentId']),
    setType: {
      get: function () {
        return this.$store.state.setType
      },
      set: function(val) {
        this.$store.commit('SET_SETTYPE', val)
      }
    },
    currentComponent() {
      let list = this.pageData.componentList
      return list && list.length > 0 ? list.find(item => item.id === this.activeComponentId) : null
    }
  },
  methods: {
    ...mapActions(['pageChange']),
    editComponent(data) {
      this.pageChange({
        type: 'edit',
        id: this.activeComponentId,
        data
      })
    }
  }
}
</script>
<style lang="less">
@import url("~@/styles/icon.less");
.page-right{
  position: absolute;
  top: 56px;
  right: 0;
  bottom: 0;
  width: 376px;
  padding-bottom: 50px;
  overflow-x: hidden;
  overflow-y: auto;
  background-color: #fff;
}
//组件配置模块
.com-group{
  .el-slider{
    width: 95%;
    .el-slider__input{
      width: 60px;
    }
    .el-slider__runway{
      margin-right: 80px;
    }
  }
  .el-radio{
    line-height: 30px;
    color: #323233;
  }
}
.up-pic-item-delete{
  position: absolute;
  cursor: pointer;
  font-size: 20px;
  right: -10px;
  top: -10px;
  color: #bbb;
  background-color: #fff;
  border-radius: 50%;
  visibility: hidden;
  z-index: 2;
  &:hover{
    color: #aaa;
  }
}
</style>
